package com.invengo.module_check.ui.fragment.change_shelf.fragment;

import static com.invengo.module_check.data.entity.BundleKey.KEY_ACTION;
import static com.invengo.module_check.data.entity.BundleKey.KEY_BOOKS;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.navigation.fragment.NavHostFragment;

import com.invengo.module_check.BR;
import com.invengo.module_check.R;
import com.invengo.module_check.data.entity.ActionArgs;
import com.invengo.module_check.databinding.FragmentChangeByBookBinding;

import java.io.Serializable;

import me.goldze.mvvmhabit.base.BaseFragment;

public class ChangeByBookFragment extends BaseFragment<FragmentChangeByBookBinding, ChangeViewModel> {
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_change_by_book;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initViewObservable() {
        viewModel.ui.nextEvent.observe(this, bookBeans -> {
            Bundle bundle = new Bundle();
            bundle.putSerializable(KEY_BOOKS, (Serializable) bookBeans);
            bundle.putSerializable(KEY_ACTION, ActionArgs.ACTION_CHANGE);
            NavHostFragment.findNavController(this).navigate(ActionArgs.ACTION_CHANGE.getFirst2second(), bundle);
        });
    }
}
